<?php

namespace App\Http\Controllers;

use App\Test;
use ElemeOpenApi\Api\ProductService;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Http\Request;
use ElemeOpenApi\Config\Config;
use ElemeOpenApi\OAuth\OAuthClient;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Session;


class TestController extends Controller
{


    public function test2(Request $request)
    {
        //实例化一个配置类

        $config = new Config('NWoumwnqXk', 'cbfaf1ea4c3d3ab3c64498be7b9620e94b3cd61e', true);
        $client = new OAuthClient($config);
        $callback_url = urlencode('http://192.168.1.147/TestElm/public/test2');
        $code = $request->get('code');
        if($code){
            $token = $client->get_token_by_code($code, 'http://192.168.1.147/TestElm/public/test2');


            //查询店铺商品分类
//            $product_service =  new ProductService($token,$config);
//            $shop_id = 157677636;
//            $result = $product_service->get_shop_categories($shop_id);
            $product_service = new productService($token, $config);
            $category_id = 528342872;
            $result = $product_service->get_category_with_children($category_id);
            dd($result);
            exit;
        }
//        $callback_url = urlencode(Url()->current());
        $auth_url = $client->get_auth_url('123131232', 'all', $callback_url);
        header('location:' . $auth_url);


        exit();
    }


    public function cs(Request $request){
        echo LARAVEL_START;EXIT;
        $order = new OrderController();
        var_dumps($order->mgetOrders($request));
        exit;
    }

    public function test(Request $request)
    {

//        $a = new CategoryController();
       $a = new OrderController();
//        $a = new CommentsController();
//            dd("111111111111");
            $msg = $a->getOrder($request);
            dd($msg);
    }



}
